package com.luyuanhe.controller;

import com.luyuanhe.common.vo.ResultMessage;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;


@Slf4j
@RestController
@RequestMapping("/fund")
public class AccountController {

    @PostMapping("/account/balance/{userId}/{amount}")
    public ResultMessage deductingBalance(@PathVariable("userId") Long userId,
                                          @PathVariable("amount") Double amount,
                                          HttpServletRequest request) {
        log.info("userId:{},amount:{}", userId, amount);
        String message = "端口号 【" + request.getServerPort() + "】 扣减成功~~~~";
        ResultMessage result = new ResultMessage("200", message);
        return result;
    }
}
